﻿var sess_tp=0;
var gWLastCount=10;
function pageLoad(sender, args) 
{
  if(RECount==0)
{
GetAllSession(1,1,LUCount);
}  
}
function  fctState(id,state)
{
 var obj = document.getElementById("Form1");    
    if(obj!=null)
    {
    obj.action ='/session/session.htm?sid='+id;
    document.getElementById('op').value=state;
    obj.submit();
    }
}
//通过页面得到小黑板上面的留言
function GetAllSession(pageIndex,tp,cn)
{
showProgressBar(true);
$('sl0').className="first"; 
for(var i=1;i<4;i++)
{
  $('sl'+i).className="";  
}
$('sl'+tp).className=$('sl'+tp).className+" "+"selATags";
if(cn!=0)
{
sess_tp=tp;
$('Nosession').style.display="none"; 
     switch (sess_tp)
         {
            case 0 :
            $('myres').style.display="";
            $('Nmyres').style.display="none";
            showProgressBar(false);
            break;
            case 1 :
            $('myres').style.display="none"; 
WebServices.User.Teach.GetMyLuSessions(Memberno,pageIndex,gWLastCount,Timezone,onsucc); 
            break;
            case 2 :
            $('myres').style.display="none"; 
WebServices.User.Teach.GetMyUpSessions(Memberno,pageIndex,gWLastCount,Timezone,onsucc); 
            break;
            case 3 :
            $('myres').style.display="none"; 
WebServices.User.Teach.GetMyPsSessions(Memberno,pageIndex,gWLastCount,Timezone,onsucc); 
            break;
     }
}else
{
  $('myres').style.display="none";
  $('Nmyres').style.display="none"; 
  $('Nosession').style.display=""; 
  showProgressBar(false); 
}
    
}
//初始化小黑板数据
function onsucc(result)
{
    if(result!=null){
   RendComList(result[0],"myups");
   RendPageNavigator(result[1],"myupspage","GetPage");
   }
   showProgressBar(false);
}
//得到页面数据
function GetPage(pageIndex)
{
    gDPageIndex = pageIndex;
    showProgressBar(true);    
    GetAllSession(gDPageIndex,sess_tp,1);
}
//替换小黑板上面的信息
function RendComList(list,divID)
{
    var domDiv1 = $(divID);   
    if(domDiv1!=null)
    {
        if(Sys.UI.DomElement.containsCssClass(domDiv1, "DisplayNone"))
        {
            Sys.UI.DomElement.removeCssClass(domDiv1, "DisplayNone");
        }
        if($("SessionTemplate")==null) return;
        var item= $("SessionTemplate").innerHTML;
        var listBuilder = new Sys.StringBuilder();
        for (var index = 0; index < list.length; ++index) 
        {
            var obj = list[index];
            var tmp = item.replace(/\$Img\$/gi,obj.AudioType);
            tmp = tmp.replace(/\$MemberNo\$/gi,obj.TNO == Memberno ? obj.SNO : obj.TNO+'T');
            tmp = tmp.replace(/\$Nickname\$/gi,obj.TNO == Memberno ? obj.SNickname : obj.TNickname);
            tmp = tmp.replace(/\$SessionType\$/gi,obj.SessionType);
            tmp = tmp.replace(/\$StartDate\$/gi,obj.TToSDesc);
            tmp = tmp.replace(/\$State\$/gi,obj.SToTDesc);
            tmp = tmp.replace(/\$SessionID\$/gi,obj.SessionID);
            listBuilder.append(tmp);
        }
         $('Nmyres').style.display="";
        domDiv1.innerHTML = listBuilder.toString();
   }
}
 if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();